const crypto = require('crypto')
const user = require('../models/user')
const operateObj = require('./utils')

let obj = {
	// 新增
	addData: (body, res) => {
		let md5 = crypto.createHash('md5')
		let pass = md5.update(body.password).digest('hex')
		body.password = pass
		operateObj.add(user, body, res)
	},
	// 获取分页
	getPage: (body, res) => {
		operateObj.page(user, body, res,
		  ['username', 'nickname', 'phone', 'sex'])
	},
	// 获取列表
	getList: (body, res) => {
		operateObj.list(user, body, res)
	},
	// 获取详情
	getInfo: (body, res) => {
		operateObj.info(user, body, res)
	},
	// 更新
	updateData: (body, res) => {
		operateObj.update(user, body, res)
	},
	// 删除
	deleteData: (body, res) => {
		operateObj.del(user, body, res)
	}
}

module.exports = obj
